#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/4/15 15:04
# @Author  : Chenmm
# @File    : dict.py
# @Software: PyCharm


from app.api import api
from flask import Flask, request, g, jsonify, send_file, session, current_app
from flask_login import login_required, current_user
from app.models import SysDict, SysDictItem


# 获取字典项列表
@api.route('/dicts/<dictCode>/items')
@login_required
def getDictsOptions(dictCode):
    dict = SysDict.query.filter_by(status=1, is_deleted=0, dict_code=dictCode).first()
    data = []
    if dict is not None:
        dictItems = SysDictItem.query.filter_by(status=1, dict_code=dictCode).all()
        data = [dictItem.to_option_json() for dictItem in dictItems]

    return jsonify(
        {'code': '00000', 'data': data,
         'msg': '一切ok'})